/**
 * 
 */
package smart_campus_api;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.zhiteng.entity.School;
import com.zhiteng.entity.Teacher;
import com.zhiteng.mapper.TeacherMapper;
import com.zhiteng.service.SchoolService;
import com.zhiteng.service.TeacherService;
import com.zhiteng.utils.common.HttpClientUtil;
import com.zhiteng.utils.tencent.campus.CommonResult;
import com.zhiteng.utils.tencent.campus.SignUtil;

/**  
* <p>Title: ImportData2.java</p>  
* <p>Description: </p>  
* @author dragon  
* @date 2018年12月5日  
* @version 1.0  
*/
/**  
* <p>Title: ImportAllSchool.java</p>  
* <p>Description: </p>  
* @author dragon  
* @date 2018年11月7日  
* @version 1.0  
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring/applicationContext-dao.xml")
public class ImportData2 {
	
	@Value("${devCode}")
	private String devCode;
	@Value("${devType}")
	private String devType;
	@Value("${objType}")
	private String objType;
	@Value("${officeid}")
	private String officeid;
	
	@Value("${getAllSchoolURL}")
	private String getAllSchoolURL;
	@Value("${getSchoolInfoURL}")
	private String getSchoolInfoURL;
	
	@Autowired
	private TeacherMapper teacherMapper;
	
	
	/*@Test
	public void test() {
		long timestamp = System.currentTimeMillis();
		Map<String, String> map = new HashMap<String, String>();
		map.put("timestamp", timestamp + "");
		map.put("devCode", devCode);
		map.put("devType", devType);
		map.put("objType", objType);
		map.put("officeid", officeid);
		map.put("size", "100");
		String url = "https://m.campus.qq.com/api/open/buGetCourseA?" 
					+ "timestamp=" + timestamp 
					+ "&sign=" + SignUtil.getSign(map) 
					+ "&devCode=" + devCode
					+ "&devType=" + devType
					+ "&objType=" + objType
					+ "&officeid=" + officeid
					+ "&size=100";
		String jsonStr = HttpClientUtil.get(url);
		
		
		//	把json数据封装成CommonResult
		System.out.println(jsonStr);
		CommonResult<CourseA> result = JSON.parseObject(jsonStr, new TypeReference<CommonResult<CourseA>>(){});
		//	获取所有学校的集合
		List<CourseA> schoolList = result.getData().getDataList();
		//int count = courseAService.saveBatch(schoolList);
		//System.out.println("成功插入"+count+"条数据！");
		long endTime = System.currentTimeMillis();
		System.out.println("共耗时"+(endTime-timestamp)+"毫秒！"); //4~5s
	}
	*/
}
